Name Property Example (RDO)

The following example illustrates use of the Name property to expose the names of all tables associated with a chosen database, the names of each column for the selected table, and specific type information about a selected column. This application uses three Listbox controls and a Command button control.

Option Explicit
Dim en As rdoEnvironment
Dim cn As rdoConnection
Dim rs As rdoResultset
Dim tb As rdoTable
Dim cl As rdoColumn
Dim er As rdoError

Private Sub Command1_Click()
Set en = rdoEngine.rdoEnvironments(0)

Set cn = en.OpenConnection(dsName:="WorkDB", _
    prompt:=rdDriverNoPrompt, _
    Connect:="Uid=;pwd=;database=Pubs")

For Each tb In cn.rdoTables
    List1.AddItem tb.Name
Next
List1.ListIndex = 1
End Sub

Private Sub List1_Click()
List3.Enabled = False
List2.Clear
For Each cl In cn.rdoTables((List1)).rdoColumns
    List2.AddItem cl.Name
Next
List3.Enabled = True
End Sub

Private Sub List2_Click()
List3.Clear
With cn.rdoTables((List1)).rdoColumns((List2))
    List3.AddItem "Source Column:" & .SourceColumn
    List3.AddItem "Source Table:" & .SourceTable
    List3.AddItem "Type:" & .Type
    List3.AddItem "Size:" & .Size
    List3.AddItem "Ordinal Position:"  _
   & .OrdinalPosition
    List3.AddItem "Allow Zero Length ?" _
    & .AllowZeroLength
    List3.AddItem "Required:" & .Required
    List3.AddItem "Chunk Required?:" & .ChunkRequired
    List3.AddItem "Updatable?:" & .Updatable
End With
End Sub